<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="icon" href="favicon.ico" type="image/x-icon"/>
<title>门店列表-门店管理-{$site.BACK_NAME}</title>
<include file="Public:jscss"/>
</head>
<body>
<div class="wrap">
 <include file="Public:head"/>
 <div class="mainBody">
  <include file="Public:left"/>
  <div id="Right">
   <div class="Item hr">
    <div class="current">门店列表</div>
   </div>
   <form action="" method="post" id="quickForm">
    <b>快速搜索：</b>&nbsp;
    <input placeholder="请输入关键字" id="kwd" class="input" type="text" name="kwd" value="{$kwd}"/> &nbsp;
	<input type="submit" class="btn quickSubmit" value='搜索'/>
   </form>
   <form action="" method="post" id="tab_form">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab">
     <thead>
      <tr>
	   <td width="5%"><label><input name="" class="cfz_choose_all" type="checkbox"/> 全选</label><br/><label><input name="" class="cfz_unset_all" type="checkbox"/> 反选</label></td>
       <td width="30%">店名</td>
       <td width="5%">标识</td>
	   <td width="5%">店长</td>
	   <td width="5%">CMO</td>
	   <td width="5%">老板</td>
	   <td width="5%">CM</td>
	   <td width="5%">MS</td>
	   <td width="5%">状态</td>
	   <td width="5%">排序</td>
	   <td width="10%">添加时间</td>
       <td width="15%">操作</td>
      </tr>
     </thead>
     <volist name="list" id="vo">
     <tr align="center" id="tr_{$vo.id}">
	  <td><input type="checkbox" name="id[]" value="{$vo.id}"/></td>
      <td align="left">{$vo.name}</td>
	  <td align="left">{$vo.ident}</td>
	  <td align="left"><empty name="vo.u_csk"><span style="color:red;">未指定</span><else/>{$vo.u_csk}</empty></td>
      <td align="left"><empty name="vo.u_cmo"><span style="color:red;">未指定</span><else/>{$vo.u_cmo}</empty></td>
	  <td align="left"><empty name="vo.u_cbs"><span style="color:red;">未指定</span><else/>{$vo.u_cbs}</empty></td>
	  <td align="left"><empty name="vo.u_dcm"><span style="color:red;">未指定</span><else/>{$vo.u_dcm}</empty></td>
	  <td align="left"><empty name="vo.u_dms"><span style="color:red;">未指定</span><else/>{$vo.u_dms}</empty></td>
	  <td id="st_{$vo.id}">
	   <eq name="vo.status" value="0">
	   <font color="red">禁用</font>
	   <else/>
	   <font color="green">启用</font>
	   </eq>
	  </td>
	  <td edit="0" fd="sort">{$vo.sort}</td>
	  <td align="left">{$vo.add_time|date='Y-m-d H:i:s',###}</td>
      <td>
	   [ 
	   <a href="javascript:void(0);" class="cfz_status" val="{$vo.status}">
	   <eq name="vo.status" value="0">启用<else/>禁用</eq>
	   </a>
	   ]
	   [ <a href="{:U('Store/assess',array('storeid'=>$vo['id']))}">分值 </a> ]
	   [ <a href="{:U('Store/edt',array('id'=>$vo['id']))}">编辑 </a> ]
	   [ <a data-id="{$vo['id']}" href="javascript:void(0)" name="{$vo.name}" class="cfz_del">删除 </a> ]
	  </td>
     </tr>
     </volist>
    </table>
   </form>
   <div class="commonBtnArea" >
	<button class="btn cfz_add">添加门店</button>
    <button class="btn cfz_submit">删除所选</button>
   </div>
  </div>
 </div>
</div>
<div class="clear"></div>
<include file="Public:foot"/>
</body>
<script type="text/javascript">
$(function(){
	//快捷启用禁用操作
	$(".cfz_status").click(function(){
		var obj=$(this);
		var t_id=$(this).parents("tr").attr("id");
		t_id = t_id.replace("tr_","");
		var t_status=$(this).attr("val");
		$.getJSON("{:U('Store/opns')}", { id:t_id, status:t_status }, function(json){
			if(json.errcode==0){
				$.jBox.success(json.errmsg, '状态已改变');
				$(obj).attr("val",json.data.status).html(status==1?"启用":"禁用");
				$("#st_"+t_id).html(status==1?"<font color='red'>禁用</font>":"启用");
			}else{
				$.jBox.alert(json.errmsg, '提示信息');
			}
		});
	});
	//快捷改变操作排序dblclick
	$("tbody>tr>td[fd]").click(function(){
		var inval = $(this).html();
		var infd = $(this).attr("fd");
		var inid =  $(this).parents("tr").attr("id");
		inid = inid.replace("tr_","");
		if($(this).attr('edit')==0){
			$(this).attr('edit','1').html("<input class='input' size='1' id='edit_"+infd+"_"+inid+"' value='"+inval+"' />").find("input").select();
		}
		$("#edit_"+infd+"_"+inid).focus().bind("blur",function(){
			var editval = $(this).val();
			$(this).parents("td").html(editval).attr('edit','0');
			if(inval!=editval){
				$.post("{:U('Store/opst')}",{id:inid,sort:editval},function(){
					window.location.href=window.location.href; 
					window.location.reload;
				});
			}
		});
	});
	//跳转到添加页面
	$(".cfz_add").click(function(){
		window.location.href = "{:U('Store/add')}"; 
	});
	//单个删除
	$(".cfz_del").click(function(){
		var that = $(this);
		if($(this).data("busy") == 1){
			$.jBox.tip('已提交，系统在处理中...', 'info');
			return false;
		}
		var news_id = $(this).data("id");
		$.jBox.confirm(
			'您真的打算删除【<b>'+$(this).attr("name")+'</b>】吗?',
			"温馨提示",
			function(v, h, f) {
				if(v == 'ok'){
					that.data('busy',1);
					$.getJSON("{:U('Store/del')}", {id:news_id}, function(json){
						if(json.errcode==0){
							$("#tr_"+news_id).remove();
							$.jBox.tip(json.errmsg, 'success');
						}else{
							$.jBox.tip(json.errmsg, 'error');
						}
					});
					$.jBox.tip("系统处理中，请稍候....", 'loading');
					return true;
				}
			}
		);	
	});
	//多个删除
	$(".cfz_submit").click(function(){
		var that = $(this);
		if(that.data("busy") == 1){
			$.jBox.tip('已提交，系统在处理中...', 'info');
			return false;
		}
		if($("tbody input[type='checkbox']:checked").size()==0){
			$.jBox.tip('请先选择要删除的项', 'info');
			return false;
		}
		$.jBox.confirm(
			'您确定要删除该选定项吗?',
			"温馨提示",
			function(v, h, f) {
				if(v == 'ok'){
					that.data("busy",1);
					commonAjaxSubmit("{:U('Store/del')}", "#tab_form");
				}
			}
		);
		return false;
	});
});
</script>
</html>